package com.example;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.util.JSONPObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.LinkedHashMap;

@Controller
public class TestController {

    @Autowired
    ProxyHttpReqeust proxyHttpReqeust;

    @RequestMapping(method = RequestMethod.GET)
    public String hello(){
        return "test";
    }

    @RequestMapping("/index")
    public ResponseEntity<String> index(){
        String as = "hello";

        return new ResponseEntity<String>(as, HttpStatus.OK);
    }

    @RequestMapping("/api/**")
    @ResponseBody
    public String request(HttpServletRequest request){
        LinkedHashMap<String,String> obj=((LinkedHashMap<String,String>)proxyHttpReqeust.get(request));
        return obj.get("name");
    }

}
